package com.shop2cn.iapi.agentproducts.testcase;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.GetLastProductCurrencyBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.service.GetLastProductCurrencyCall;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;

import org.junit.*;
import org.junit.experimental.categories.Category;
/**
*查询商户上次发布商品的币种
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetLastProductCurrency{
	private static GetLastProductCurrencyBean getlastproductcurrencyBean;
	private static GetLastProductCurrencyCall getlastproductcurrencyCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询商户上次发布商品的币种");
	}

	@Before
	public void caseUp() {
		getlastproductcurrencyBean=new GetLastProductCurrencyBean();
		getlastproductcurrencyCall=new GetLastProductCurrencyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getlastproductcurrencyCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	public static void main(String[] args) {
		System.out.println("aaa");
		
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetLastProductCurrency_01() {
		Logger.start(true,"查询商户上次发布商品的币种");
		try {
			createmchBean createmchBean = GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(createmchBean.getMchId(),createmchBean.getNickName(),false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			getlastproductcurrencyBean.setUserId(createmchBean.getMchId());
			getlastproductcurrencyCall.setData(getlastproductcurrencyBean);
			getlastproductcurrencyCall.callService();			

			Logger.verifyEquals("200",getlastproductcurrencyCall.getString("code"),"验证code");
			Logger.verifyEquals(addAgentProductBean.getCurrency(),getlastproductcurrencyCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),"验证currency");

			ModifyAgentProductBean modifyAgentProductBean = AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.setCurrency("USD");
			AddAgentProductCallService.modifyAgentProduct(modifyAgentProductBean);
			

			getlastproductcurrencyBean.setUserId(createmchBean.getMchId());
			getlastproductcurrencyCall.setData(getlastproductcurrencyBean);
			getlastproductcurrencyCall.callService();

			Logger.verifyEquals("200",getlastproductcurrencyCall.getString("code"),"验证code");
			Logger.verifyEquals(modifyAgentProductBean.getCurrency(),getlastproductcurrencyCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),"验证currency");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}